﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

using Maticsoft.Common;
using LTP.Accounts.Bus;
using DQYT.HTDZ.BLL;
using DQYT.HTDZ.Model;
namespace DQYT.HTDZ.Web.BDDICT
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsDecimal(txtTABLE_ID.Text))
			{
				strErr+="TABLE_ID格式错误！\\n";	
			}
			if(this.txtFIELD_CODE.Text.Trim().Length==0)
			{
				strErr+="FIELD_CODE不能为空！\\n";	
			}
			if(this.txtFIELD_NAME.Text.Trim().Length==0)
			{
				strErr+="FIELD_NAME不能为空！\\n";	
			}
			if(this.txtFIELD_TYPE.Text.Trim().Length==0)
			{
				strErr+="FIELD_TYPE不能为空！\\n";	
			}
			if(this.txtFIELD_NULL.Text.Trim().Length==0)
			{
				strErr+="FIELD_NULL不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtFIELD_LONG.Text))
			{
				strErr+="FIELD_LONG格式错误！\\n";	
			}
			if(this.txtFIELD_KEY.Text.Trim().Length==0)
			{
				strErr+="FIELD_KEY不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtFIELD_SHOWWIDTH.Text))
			{
				strErr+="FIELD_SHOWWIDTH格式错误！\\n";	
			}
			if(this.txtFIELD_SHOW.Text.Trim().Length==0)
			{
				strErr+="FIELD_SHOW不能为空！\\n";	
			}
			if(this.txtFIELD_POPWIN.Text.Trim().Length==0)
			{
				strErr+="FIELD_POPWIN不能为空！\\n";	
			}
			if(this.txtFIELD_DATASOURCE.Text.Trim().Length==0)
			{
				strErr+="FIELD_DATASOURCE不能为空！\\n";	
			}
			if(this.txtFIELD_AUTOCOL.Text.Trim().Length==0)
			{
				strErr+="FIELD_AUTOCOL不能为空！\\n";	
			}
			if(this.txtFIELD_UNIQUE.Text.Trim().Length==0)
			{
				strErr+="FIELD_UNIQUE不能为空！\\n";	
			}
			if(this.txtFIELD_ID.Text.Trim().Length==0)
			{
				strErr+="FIELD_ID不能为空！\\n";	
			}
			if(this.txtTABLE_CODE.Text.Trim().Length==0)
			{
				strErr+="TABLE_CODE不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			decimal TABLE_ID=decimal.Parse(this.txtTABLE_ID.Text);
			string FIELD_CODE=this.txtFIELD_CODE.Text;
			string FIELD_NAME=this.txtFIELD_NAME.Text;
			string FIELD_TYPE=this.txtFIELD_TYPE.Text;
			string FIELD_NULL=this.txtFIELD_NULL.Text;
			decimal FIELD_LONG=decimal.Parse(this.txtFIELD_LONG.Text);
			string FIELD_KEY=this.txtFIELD_KEY.Text;
			decimal FIELD_SHOWWIDTH=decimal.Parse(this.txtFIELD_SHOWWIDTH.Text);
			string FIELD_SHOW=this.txtFIELD_SHOW.Text;
			string FIELD_POPWIN=this.txtFIELD_POPWIN.Text;
			string FIELD_DATASOURCE=this.txtFIELD_DATASOURCE.Text;
			string FIELD_AUTOCOL=this.txtFIELD_AUTOCOL.Text;
			string FIELD_UNIQUE=this.txtFIELD_UNIQUE.Text;
			string FIELD_ID=this.txtFIELD_ID.Text;
			string TABLE_CODE=this.txtTABLE_CODE.Text;

			BDDICTModel model=new BDDICTModel();
			model.TABLE_ID=TABLE_ID;
			model.FIELD_CODE=FIELD_CODE;
			model.FIELD_NAME=FIELD_NAME;
			model.FIELD_TYPE=FIELD_TYPE;
			model.FIELD_NULL=FIELD_NULL;
			model.FIELD_LONG=FIELD_LONG;
			model.FIELD_KEY=FIELD_KEY;
			model.FIELD_SHOWWIDTH=FIELD_SHOWWIDTH;
			model.FIELD_SHOW=FIELD_SHOW;
			model.FIELD_POPWIN=FIELD_POPWIN;
			model.FIELD_DATASOURCE=FIELD_DATASOURCE;
			model.FIELD_AUTOCOL=FIELD_AUTOCOL;
			model.FIELD_UNIQUE=FIELD_UNIQUE;
			model.FIELD_ID=FIELD_ID;
			model.TABLE_CODE=TABLE_CODE;

			BDDICTBLL bll=new BDDICTBLL();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
